`ifndef __ISE__

`include "code\source\P2\scrambler.v"
`include "code\source\P2\hamming_decoder.v"
`include "code\source\P2\interleaver.v"

`endif

module channel_decoder (
           input clk,
           input clk2,
           input rst_n,
           input din,
           input din_valid,
           output dout,
           output dout_valid);

wire interleaver_dout, interleaver_valid;

interleaver Interleaver(
                .clk2 (clk2 ),
                .rst_n (rst_n ),
                .din (din ),
                .din_valid (din_valid ),
                .dout (interleaver_dout ),
                .dout_valid (interleaver_valid )
            );

wire hamming_dout, hamming_dout_valid;

hamming_decoder Hamming_decoder(
                    .clk (clk ),
                    .clk2 (clk2 ),
                    .rst_n (rst_n ),
                    .din (interleaver_dout),
                    .din_valid (interleaver_valid),
                    .dout (hamming_dout ),
                    .dout_valid (hamming_dout_valid )
                );

scrambler Scrambler(
              .clk (clk ),
              .rst_n (rst_n ),
              .seed (7'b0),
              .load (1'b0),
              .din (hamming_dout ),
              .din_valid (hamming_dout_valid ),
              .dout (dout ),
              .dout_valid (dout_valid )
          );


endmodule
